import { useEffect, useRef, useState } from 'react';
import './App.css';

// TODO: https://github.com/alibaba/hooks/tree/master/packages/hooks/src

function useSetInterval(delayTime, callbackFn){
  const timerRef = useRef(null);
  useEffect(() => {
    if (delayTime < 0) return;
    timerRef.current = setTimeout(() => {
      callbackFn();
    }, delayTime);
    return () => {
      if (timerRef.current) {
        clearTimeout(timerRef.current);
      }
    };
  }, [delayTime]);
}

function App() {
  const [count, setCount] = useState();
  useSetInterval(500, ()=>{
    console.log('-------');
  });
  return (
    <div className="App">
      
    </div>
  );
}

export default App;
